package net.hn.hnms.biz.safety.trinity.company.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.hn.hnms.biz.safety.trinity.company.service.HiddanGroupDangerRecordCompanyService;
import net.hn.hnms.biz.safety.trinity.company.service.RiskControlCompanyService;
import net.hn.hnms.biz.safety.trinity.company.service.WorkSafetyViolationCompanyService;
import net.hn.hnms.biz.safety.trinity.entity.HiddenDangerSumVO;
import net.hn.hnms.biz.safety.trinity.entity.RiskHiddenDangerLevelVO;
import net.hn.hnms.biz.safety.trinity.entity.SecurityLevelVO;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import net.hn.hnms.biz.api.safety.trinity.model.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 智呈物联 nzw
 * @date 2023/1/5
 */

@RestController
@RequestMapping("company/manage/double")
@Api(value = "安全风险双预控公司端控制器", tags = {"安全风险双预控公司端"})
public class ManageDoubleCompanyController {

    private HiddanGroupDangerRecordCompanyService hiddanGroupDangerRecordCompanyService;

    private RiskControlCompanyService riskControlCompanyService;

    private WorkSafetyViolationCompanyService workSafetyViolationCompanyService;

    @Autowired
    public void setHiddanGroupDangerRecordCompanyService(HiddanGroupDangerRecordCompanyService hiddanGroupDangerRecordCompanyService) {
        this.hiddanGroupDangerRecordCompanyService = hiddanGroupDangerRecordCompanyService;
    }

    @Autowired
    public void setRiskControlCompanyService(RiskControlCompanyService riskControlCompanyService) {
        this.riskControlCompanyService = riskControlCompanyService;
    }

    @Autowired
    public void setWorkSafetyViolationCompanyService(WorkSafetyViolationCompanyService workSafetyViolationCompanyService) {
        this.workSafetyViolationCompanyService = workSafetyViolationCompanyService;
    }

    @GetMapping("hiddenDangerCheck")
    @ApiOperation("隐患排查")
    public R<HiddenDangerCheckVo> hiddenDangerCheck(){
        return R.ok(hiddanGroupDangerRecordCompanyService.hiddenDangerCheck());
    }

    @GetMapping("riskControl")
    @ApiOperation("风险管控")
    @AutoSetMineCode
    public R<RiskControlVo> riskControl(String companyCode) {
        return R.ok(riskControlCompanyService.riskControl(companyCode));
    }

    @GetMapping("dangerInformation")
    @ApiOperation("隐患信息")
    public R<DangerInfoVo> hiddenDanger() {
        //todo
        return R.ok(hiddanGroupDangerRecordCompanyService.hiddenDanger());
    }

    @GetMapping("threeViolations")
    @ApiOperation("三违管理")
    @AutoSetMineCode
    public R<TreeViolationsManagementVo> threeViolations(String companyCode) {
        return R.ok(workSafetyViolationCompanyService.threeViolations());
    }

    @GetMapping("hiddenDangerSum")
    @ApiOperation("按隐患所属单位统计")
    public R<HiddenDangerSumVO> hiddenDangerSum(){
        return R.ok(hiddanGroupDangerRecordCompanyService.hiddenDangerSum());
    }

    @GetMapping("securityLevel")
    @ApiOperation("煤矿安全生产标准化")
    public R<List<SecurityLevelVO>> securityLevel(){
        List<SecurityLevelVO> levelVOS = new ArrayList<>();
        SecurityLevelVO yanbei = new SecurityLevelVO();
        yanbei.setLevel("1");
        yanbei.setName("620824009734");
        levelVOS.add(yanbei);
//        SecurityLevelVO gaotouyao = new SecurityLevelVO();
//        gaotouyao.setLevel("1");
//        gaotouyao.setName("");
//        levelVOS.add(gaotouyao);
        return R.ok(levelVOS);
    }

    @GetMapping("hiddenDangerCount")
    @ApiOperation("安全综合概览-安全隐患")
    public R<HiddenDangerCountVO> hiddenDangerCount(){
        return R.ok(hiddanGroupDangerRecordCompanyService.hiddenDangerCount());
    }

    @GetMapping("levelConstitute")
    @ApiOperation("安全决策-双重预防-年风险隐患等级构成")
    public R<RiskHiddenDangerLevelVO> levelConstitute(){
        RiskHiddenDangerLevelVO riskHiddenDangerLevelVO = new RiskHiddenDangerLevelVO();
        hiddanGroupDangerRecordCompanyService.getHiddenDangerLevelYear(riskHiddenDangerLevelVO);
        riskControlCompanyService.getRiskLevelYear(riskHiddenDangerLevelVO);

        return R.ok(riskHiddenDangerLevelVO);
    }
}
